package valutatore;

import java.util.ArrayList;

public class Fun extends Expr {

	private ArrayList<Ident> params;	
	private ArrayList<Ident> locals;	
	private Expr expr;
	
	public Fun(ArrayList<Ident> params, ArrayList<Ident> locals, Expr expr) {
		this.params = params;
		this.locals = locals;
		this.expr = expr;
	}

	public Fun(Expr expr) {
		this(new ArrayList<Ident>(), new ArrayList<Ident>(), expr);
	}
	
	@Override
	public Value eval(Env env) {
		//Una Closure esiste solo in esecuzione, come risultato della valutazione di una funzione.
		return new Closure(env, this);
	}

	public ArrayList<Ident> getParams() {
		return params;
	}

	public void setParams(ArrayList<Ident> params) {
		this.params = params;
	}

	public ArrayList<Ident> getLocals() {
		return locals;
	}

	public void setLocals(ArrayList<Ident> locVar) {
		this.locals = locVar;
	}

	public Expr getExpr() {
		return expr;
	}

	public void setExpr(Expr expr) {
		this.expr = expr;
	}
}
